
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.FileOutputStream;
import java.io.IOException;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author roparsbe
 */
public class pdfGenerator {
     /** Path to the resulting PDF file. */
    public static final String RESULT
        = "hello.pdf";

    /**
     * Creates a PDF file: hello.pdf
     * @param    args    no arguments needed
     */
    public static void main(String[] args)
    	throws DocumentException, IOException {
    	new pdfGenerator().createPdf(RESULT);
    }

    /**
     * Creates a PDF document.
     * @param filename the path to the new PDF document
     * @throws    DocumentException
     * @throws    IOException
     */
    public void createPdf(String filename)
	throws DocumentException, IOException {
        // step 1
        Document document = new Document();
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        // step 3
        document.open();
        // step 4

        Paragraph date = new Paragraph(" 20/01/2011 ");
        date.setAlignment(Paragraph.ALIGN_RIGHT);
        document.add(date);

        document.add(new Paragraph("Docteur DUPONT Jacques"));
        document.add(new Paragraph("20 rue des alluets"));
        document.add(new Paragraph("29200 BREST"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Docteur Généraliste ancien interne "));
        document.add(new Paragraph("59.012001"));

        Paragraph patient = new Paragraph(new Phrase    ("              George LUCAS            "));
        patient.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(patient);
        
        Paragraph patientInfo = new Paragraph(new Phrase("              taille: 1.45m  Poid:55kg"));
        patientInfo.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(patientInfo);

        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));

        document.add(new Paragraph("DEPAKOTE 500mg cp gastrrésis                                             1 boite         "));
        document.add(new Paragraph("Prendre 1 comprimés par jour, pendant 5 jours."));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("DOLIPRANE 500mg cp                                                            2 boites         "));
        document.add(new Paragraph("Prendre 3 comprimés par jour, pendant 1 semaine."));


       for(int i = 0 ; i < 9 ; i++){
            document.add(new Paragraph(" "));
        }
        Paragraph renou = new Paragraph("Renouveler 3 fois");
        renou.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(renou);


        for(int i = 0 ; i < 13 ; i++){
            document.add(new Paragraph(" "));
        }


        Paragraph pied = new Paragraph("En cas d'urgence : 0899 026 307 ");
        pied.setAlignment(Paragraph.ALIGN_BOTTOM);
        document.add(pied);
        
        // step 5
        document.close();
    }


}
